{% extends "base.volt" %}

{% block pageFooter%}
    {{ javascript_include("/assets/manage/js/qaadd/list.js", false) }}
{% endblock %}

{% block content %}
    <div class="container-fluid" id="content_box_blank">
        <div class="row">
            <div class="col-xs-12">

                <div class="panel panel-default">
                    <div class="panel-body">
                        <form class="form-inline" role="form" action="" method="get">
                            <input type="hidden" name="filterOrder" value="{{ filterOrder }}" />
                            <div class="form-group">
                                <div class="input-group">
                                    <label class="input-group-addon" for="filterTag">分类:</label>
                                    <select class="form-control" name="filterTag" id="filterTag">\
                                        <option value="-10000" {{ filterTag == -10000 ? 'selected="selected"' : '' }} >全部</option>
                                        {% for t in tagList  %}
                                            <option value="{{ t.tag_id }}" {{ filterTag == t.tag_id ? 'selected="selected"' : '' }} >{{ t.tag_title }}</option>
                                        {%  endfor %}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <button type="submit" class="btn btn-primary"><i class="fa fa-filter"></i> 搜 索</button>
                            </div>

                            <div class="pull-right">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" id="order_id" {{ filterOrder == 0 ? 'checked="checked"' : '' }}> 新增加的排序
                                    </label>
                                </div>
                                <div class="checkbox" style="margin-left: 10px">
                                    <label>
                                        <input type="checkbox" id="order_answer" {{ filterOrder == 1 ? 'checked="checked"' : '' }}> 回答数排序
                                    </label>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th style="width: 60px;">ID</th>
                        <th style="width: 200px;">用户</th>
                        <th style="width: 100px;">分类</th>
                        <th>内容</th>
                        <th style="width: 100px;">回答/关注</th>
                        <th style="width: 60px;">状态</th>
                        <th style="width: 180px;">提问时间</th>
                        <th style="width: 200px;"></th>
                    </tr>
                    </thead>
                    {% for d in data %}
                        <tr>
                            <td>{{ d.question_id }}</td>
                            <td>{{ d.user_nickname|e }}</td>
                            <td>{{ d.tag_title|e }}</td>
                            <td>{{ d.question_content|e }}
                                <div class="question_photos_box">
                                    {% for pic in json_decode(d.question_pics) %}
                                        <div class="pic_list">
                                            <a href="{{ PicUrlQuestion(pic, this.getDi()) }}" class="thumbnail" target="_blank">
                                                <img src="{{ PicUrlQuestion(pic, this.getDi()) }}@!120" alt="" />
                                            </a>
                                        </div>
                                    {% endfor %}
                                </div>
                            </td>
                            <td>{{ d.answer_num }} / {{ d.question_follows }}</td>
                            <td>{{ GeneralStateValue2Str(d.question_state) }}</td>
                            <td>{{ d.question_addtime }}</td>
                            <td>
                                <div class="btn-group btn-group-sm" role="group">
                                <a class="btn btn-default" href="/frontend/share/question?id={{ d.question_id }}" target="_blank"><i class="fa fa-eye fa-fw"></i> 预览</a>
                                <a class="btn btn-default" href="/manage/questionmanage/info?id={{d.question_id}}"><i class="fa fa-info fa-fw"></i> 回答</a>
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                </table>

                {{ this.tagNav.page(
                page,
                total,
                limit,
                url.get('qaadd/list', [
                    'filterTag': filterTag,
                    'filterOrder': filterOrder,
                    'page': '__PAGE__'
                ]
                )) }}
            </div>
        </div>
    </div>
{% endblock %}